<template>
	<view>
		<!-- 时间 -->
		<view class="flex align-center justify-center py-2 text-light-muted font-sm" v-if="shortTime">
			{{shortTime}}
		</view>
		<!-- 消息气泡 -->
		<view class="flex align-start px-2 my-2" :style="isSelf ? 'flex-direction: row-reverse;' : ''">
			<image :src="item.avatar" style="width: 100rpx; height: 100rpx;" class="rounded-circle" mode="">
			</image>
			<view class="bg-light p-2 rounded mx-2 text-center" style="max-width: 400rpx; min-width: 100rpx;">
				{{item.data}}
			</view>
		</view>
	</view>
</template>

<script>
	//模拟当前用户的user_id
	const uid = 1
	import $T from '@/common/time.js'
	export default {
		props: {
			item: Object,
			index: Number,
			pretime: [Number, String]
		},
		computed: {
			isSelf() {
				return uid === this.item.user_id
			},
			// 转换时间
			shortTime() {
				return $T.getChatTime(this.item.create_time, this.pretime)
			}
			
		},
		
	}
</script>

<style>
</style>